/**
 * Created by Xing on 2015/4/30.
 */
package {

import flash.display.Sprite;
import flash.media.Sound;
import flash.media.SoundLoaderContext;
import flash.net.URLRequest;

public class URLMp3 extends Sprite{
    public function URLMp3() {

        // get current url of swf not html
        var x:String = this.loaderInfo.url;
        var url:String = '';

        if(x.indexOf('?')!=-1&&x.indexOf('&')!=-1){
            url = ParseURL(x);
            var s:Sound = new Sound();
            var req:URLRequest = new URLRequest(url);
            var context:SoundLoaderContext = new SoundLoaderContext(1000,true);
            s.load(req,context);
            s.play(0,9999);
        }

    }
    public static function ParseURL(URLSwf:String):String{

        var locQ:int = URLSwf.indexOf('?');
        var baseURL:String = URLSwf.slice(locQ+5,-17);
        return baseURL
    }
}
}
